#include <stdio.h>

#include "../uch.h"

int
main(int argc, const char *argv[])
{
	/* a unicode character */
	Uch ch;
	/* a unicode character length */
	size_t len;
	/* a unicode string */
	const char str[] = "a£∃🆒";
	const char rev[] = "\0🗨∀¡b";
	/* position pointer*/
	const char *pos;

	/* iterate through the string printing characters */
	for (pos = str; *pos; pos += len) {
		ch = uch(pos, &len);
		printf("char: " PRI_UCH ", len: %zu\n", &ch, len);
	}

	/* iterate in reverse to start of string */
	pos = rev + sizeof(rev) - 1;

	while (pos -= (len = ch_lenb(pos)), *pos) {
		/* printf("pos: %s\n", pos); */
		ch = uch(pos, NULL);
		printf("char: " PRI_UCH ", len: %zu\n", &ch, len);
	}

	return 0;
}
